`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date: 2025/01/25 12:09:50
// Design Name: 
// Module Name: TOP
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//////////////////////////////////////////////////////////////////////////////////


module top_module (
			rst,
			key,key2,
			led,led2,
			beeper_out,
			led_G,
			led_2812,
			oled_rst,	//OLCD濠电姷鏁告慨鐑藉极閸涘﹥鍙忛柣鎴ｆ閺嬩線鏌熼梻瀵割槮缁炬儳顭烽弻锝夊箛椤掍焦鍎撻梺鎼炲妼閸婂灝顫忔繝姘唶闁绘柨澧庣换渚€姊洪幖鐐测偓鏍洪悢鐓庣畺閻熸瑥瀚ㄩ崑濠囨偡娴ｉ潧鈧劙宕戦幘璇茬劦妞ゆ帒瀚悡娑㈡倵閿濆簼绨介弫鍫ユ⒑閸濆嫮鐒跨紒鎻掆偓鐔轰航闂備礁鎲＄换鍌溾偓姘煎弮瀹曟劖鎯旈埦鈧弨浠嬫煟閹邦垰鐨洪柣鎺撳劤闇夋繝濠傜凹闁垶鏌熼鍡欑瘈妞ゃ垺娲熼弫鍐焵椤掑嫭鍊峰┑鐘叉处閻撳繐鈹戦悩鑼婵＄虎鍣ｉ弻娑欐償閿熺媭鈧鏌嶇憴鍕伌婵￠箖浜堕幃妯跨疀閿濆嫰鍋楀銈冨灪娣囨椽藝鐟欏嫮绡€闁逞屽墯缁楃喖鍩€椤掆偓椤繐煤椤忓嫮顔囬柟鑹版彧缁插潡鎮鹃悽鐢电＝濞达綀娅ｇ敮娑㈡煕閵娿儳绉洪柛鈹惧亾濡炪倖甯婇懗鍫曞疮閺屻儲鐓欓柛鎴欏€栫€氾拷
			oled_dcn,	//OLCD闂傚倸鍊搁崐鎼佸磹閹间礁纾圭€瑰嫭鍣磋ぐ鎺戠倞鐟滄粌霉閺嶎厽鐓忓┑鐐靛亾濞呭棝鏌涢妶鍛伃闁哄被鍊楃划娆戞崉閵娿倗椹虫繝鐢靛仜閹虫劖鎱ㄩ崹顐も攳濠电姴娲ゅ洿闂佺鏈惌顔界珶閺囥垺鈷掑ù锝夘棑娑撹尙绱掗煫顓犵煓闁诡喗锚椤繃娼忛埡鍐殽闂備胶绮濠氬储瑜旈幃鐐哄垂椤愮姳绨婚梺鍦劋閸ㄧ敻顢旈銈傚亾鐟欏嫭灏紒鑸靛哺瀵鎮㈤崗鐓庝罕闂佸壊鍋嗛崰鎾诲礄閿熺姵鈷戠紓浣姑慨鍥煥閺囥劋閭€殿喖顭锋俊鎼佸煛娴ｈ櫣娼夐梻浣规偠閸庢椽鎮￠崼婢盯宕熼娑樹哗濠殿喗锕╅崣蹇涙嚀閹稿孩鍙忓┑鐘插鐢盯鏌熷畡鐗堝櫤缂佹鍠栭、娑樷槈濞嗘劖顔夐梻鍌氬€烽悞锕€顪冮崸妤€鍌ㄩ柣鎾崇瘍濞差亶鏁囬柣鎰仛濞堟儳鈹戦濮愪粶闁稿鎸搁埞鎴﹀焺閸愵亝鎲欏銈忕畱瀵爼銆冮妷鈺傚€烽柍杞版婢癸拷
			oled_clk,	//OLCD闂傚倸鍊搁崐鎼佸磹閹间礁纾瑰瀣捣閻棗銆掑锝呬壕濡ょ姷鍋為悧鐘汇€侀弴銏℃櫇闁逞屽墴閹潡顢欐慨鎰盎闂佽婢橀悥鐓庮瀶椤曗偓閺屾稓鈧綆浜跺Σ鎼佹煃鐟欏嫬鐏寸€规洘甯掗…銊︽償閿濆懎歇缂傚倸鍊烽懗鑸垫叏閹惰棄纭€闁规儼妫勯拑鐔兼煟閺冨倸甯剁紒鐘虫皑閹茬顭ㄩ崼婵嗘優闂佺粯鏌ㄩ崥瀣偂閸愵喗鐓熼柣鏃傤焾椤ュ寮崼銉︹拺闁告繂瀚€氭壆绱掓径搴綈濞ｅ洤锕幃婊堟寠婢光斂鍔戦弻鏇熷緞濞戙垺顎嶉梺浼欒缁蹭粙鍩為幋锔藉亹闁割煈鍋呭В鍕⒑缁嬪灝顒㈤柛銊ユ健閻涱喛绠涘☉娆愭闂佽法鍣﹂幏锟�
			oled_dat	//OLCD闂傚倸鍊搁崐鎼佸磹閹间礁纾圭€瑰嫭鍣磋ぐ鎺戠倞鐟滄粌霉閺嶎厽鐓忓┑鐐靛亾濞呭棝鏌涢妶鍛伃闁哄被鍊楃划娆戞崉閵娿倗椹虫繝鐢靛仜閹虫劖鎱ㄩ崹顐も攳濠电姴娲ゅ洿闂佺鏈惌顔界珶閺囥垺鈷掑ù锝夘棑娑撹尙绱掗煫顓犵煓闁诡喗锚椤繄鎹勯搹璇″數闂備礁鎲＄粙鎺戭焽濞嗘挸绠查柤鍝ュ仯娴滄粓鏌熼幆褜鍤熼柍顖涙礋閺屸剝鎷呴悜妯绘瘓濠殿喖锕︾划顖炲箯閸涙潙浼犻柛鏇ㄤ簽缁憋箓姊绘担渚劸闂佸府绲剧粋宥囨崉閾忚娈惧銈嗙墱閸嬫稓绮绘导鏉戠閺夊牆澧介幃鍏笺亜閺冣偓濞茬喎顫忛搹瑙勫磯闁靛鍎查悵銏ゆ⒑閻熸澘娈╅柟鍑ゆ嫹	
			);
		 wire  clk;
		//闂備礁鎲￠崝鏇㈠箠濮椻偓瀹曟洟鏁撻敓锟�12M闂備礁鎼崯顐︽偉婵傜绠伴柨鐕傛嫹
		HSOSC #(
		.CLKHF_DIV ("0b10")//0b00 = 48 MHz, 0b01 = 24 MHz, 0b10 = 12 MHz, 0b11 = 6 MHz
		) OSCInst0 ( 
		.CLKHFEN (1'b1   ), 
		.CLKHFPU (1'b1   ), 
		.CLKHF   (clk)
		);
        input             	rst;
        input 	          	key; 
		input				key2;
	    output   reg      	led,led2,led_G; 
		output				beeper_out;
		output				led_2812;

		output				oled_rst;	//OLCD濠电姷鏁告慨鐑藉极閸涘﹥鍙忛柣鎴ｆ閺嬩線鏌熼梻瀵割槮缁炬儳顭烽弻锝夊箛椤掍焦鍎撻梺鎼炲妼閸婂灝顫忔繝姘唶闁绘柨澧庣换渚€姊洪幖鐐测偓鏍洪悢鐓庣畺閻熸瑥瀚ㄩ崑濠囨偡娴ｉ潧鈧劙宕戦幘璇茬劦妞ゆ帒瀚悡娑㈡倵閿濆簼绨介弫鍫ユ⒑閸濆嫮鐒跨紒鎻掆偓鐔轰航闂備礁鎲＄换鍌溾偓姘煎弮瀹曟劖鎯旈埦鈧弨浠嬫煟閹邦垰鐨洪柣鎺撳劤闇夋繝濠傜凹闁垶鏌熼鍡欑瘈妞ゃ垺娲熼弫鍐焵椤掑嫭鍊峰┑鐘叉处閻撳繐鈹戦悩鑼婵＄虎鍣ｉ弻娑欐償閿熺媭鈧鏌嶇憴鍕伌婵￠箖浜堕幃妯跨疀閿濆嫰鍋楀銈冨灪娣囨椽藝鐟欏嫮绡€闁逞屽墯缁楃喖鍩€椤掆偓椤繐煤椤忓嫮顔囬柟鑹版彧缁插潡鎮鹃悽鐢电＝濞达綀娅ｇ敮娑㈡煕閵娿儳绉洪柛鈹惧亾濡炪倖甯婇懗鍫曞疮閺屻儲鐓欓柛鎴欏€栫€氾拷
		output				oled_dcn;	//OLCD闂傚倸鍊搁崐鎼佸磹閹间礁纾圭€瑰嫭鍣磋ぐ鎺戠倞鐟滄粌霉閺嶎厽鐓忓┑鐐靛亾濞呭棝鏌涢妶鍛伃闁哄被鍊楃划娆戞崉閵娿倗椹虫繝鐢靛仜閹虫劖鎱ㄩ崹顐も攳濠电姴娲ゅ洿闂佺鏈惌顔界珶閺囥垺鈷掑ù锝夘棑娑撹尙绱掗煫顓犵煓闁诡喗锚椤繃娼忛埡鍐殽闂備胶绮濠氬储瑜旈幃鐐哄垂椤愮姳绨婚梺鍦劋閸ㄧ敻顢旈銈傚亾鐟欏嫭灏紒鑸靛哺瀵鎮㈤崗鐓庝罕闂佸壊鍋嗛崰鎾诲礄閿熺姵鈷戠紓浣姑慨鍥煥閺囥劋閭€殿喖顭锋俊鎼佸煛娴ｈ櫣娼夐梻浣规偠閸庢椽鎮￠崼婢盯宕熼娑樹哗濠殿喗锕╅崣蹇涙嚀閹稿孩鍙忓┑鐘插鐢盯鏌熷畡鐗堝櫤缂佹鍠栭、娑樷槈濞嗘劖顔夐梻鍌氬€烽悞锕€顪冮崸妤€鍌ㄩ柣鎾崇瘍濞差亶鏁囬柣鎰仛濞堟儳鈹戦濮愪粶闁稿鎸搁埞鎴﹀焺閸愵亝鎲欏銈忕畱瀵爼銆冮妷鈺傚€烽柍杞版婢癸拷
		output				oled_clk;	//OLCD闂傚倸鍊搁崐鎼佸磹閹间礁纾瑰瀣捣閻棗銆掑锝呬壕濡ょ姷鍋為悧鐘汇€侀弴銏℃櫇闁逞屽墴閹潡顢欐慨鎰盎闂佽婢橀悥鐓庮瀶椤曗偓閺屾稓鈧綆浜跺Σ鎼佹煃鐟欏嫬鐏寸€规洘甯掗…銊︽償閿濆懎歇缂傚倸鍊烽懗鑸垫叏閹惰棄纭€闁规儼妫勯拑鐔兼煟閺冨倸甯剁紒鐘虫皑閹茬顭ㄩ崼婵嗘優闂佺粯鏌ㄩ崥瀣偂閸愵喗鐓熼柣鏃傤焾椤ュ寮崼銉︹拺闁告繂瀚€氭壆绱掓径搴綈濞ｅ洤锕幃婊堟寠婢光斂鍔戦弻鏇熷緞濞戙垺顎嶉梺浼欒缁蹭粙鍩為幋锔藉亹闁割煈鍋呭В鍕⒑缁嬪灝顒㈤柛銊ユ健閻涱喛绠涘☉娆愭闂佽法鍣﹂幏锟�
		output				oled_dat;	//OLCD闂傚倸鍊搁崐鎼佸磹閹间礁纾圭€瑰嫭鍣磋ぐ鎺戠倞鐟滄粌霉閺嶎厽鐓忓┑鐐靛亾濞呭棝鏌涢妶鍛伃闁哄被鍊楃划娆戞崉閵娿倗椹虫繝鐢靛仜閹虫劖鎱ㄩ崹顐も攳濠电姴娲ゅ洿闂佺鏈惌顔界珶閺囥垺鈷掑ù锝夘棑娑撹尙绱掗煫顓犵煓闁诡喗锚椤繄鎹勯搹璇″數闂備礁鎲＄粙鎺戭焽濞嗘挸绠查柤鍝ュ仯娴滄粓鏌熼幆褜鍤熼柍顖涙礋閺屸剝鎷呴悜妯绘瘓濠殿喖锕︾划顖炲箯閸涙潙浼犻柛鏇ㄤ簽缁憋箓姊绘担渚劸闂佸府绲剧粋宥囨崉閾忚娈惧銈嗙墱閸嬫稓绮绘导鏉戠閺夊牆澧介幃鍏笺亜閺冣偓濞茬喎顫忛搹瑙勫磯闁靛鍎查悵銏ゆ⒑閻熸澘娈╅柟鍑ゆ嫹		
        
        //u1_key_debounce 
        wire                key1_pulse;
		
        //u2_key2_debounce 
        wire                key2_pulse;
		
        //u3_time_ctrl
		wire 	[7:0]	curr_hour1      ;
		wire 	[7:0]	curr_hour0      ;
		wire 	[7:0]	curr_min1       ;
		wire 	[7:0]	curr_min0       ;
		wire 	[7:0]	curr_sec1       ;
		wire 	[7:0]	curr_sec0       ;
		wire 	[7:0]	next_hour1      ;
		wire 	[7:0]	next_hour0      ;
		wire 	[7:0]	next_min1       ;
		wire 	[7:0]	next_min0       ;
		wire 	[7:0]	next_sec1       ;
		wire 	[7:0]	next_sec0       ;
		wire  	[7:0]	diff_hour1      ;
		wire  	[7:0]	diff_hour0      ;
		wire  	[7:0]	diff_min1       ;
		wire  	[7:0]	diff_min0       ;
		wire  	[7:0]	diff_sec1       ;
		wire  	[7:0]	diff_sec0       ;
		wire 	  		beeper_start	;
		wire 			beeper_stop		;
		wire 			beeper_switch   ;
		wire			beeper_en		;
		wire	[5:0]	curr_hour		;
		
        
        //u5_key1_decode
        wire    [3:0]       oled_mode;  
		
		
		//u6_key2_mode7_decode
		wire 	[3:0]		key2_mode7;

		//u5_OLED12864
		wire				oled_csn;	//OLCD濠电姷鏁告慨鐑藉极閸涘﹥鍙忛柣鎴ｆ閺嬩線鏌熼梻瀵割槮缁炬儳顭烽弻锝夊箛椤掍焦鍎撻梺鎼炲妼閸婂灝顫忔繝姘唶闁绘柨澧庣换渚€姊洪幖鐐测偓鏍洪悢鐓庣畺閻熸瑥瀚ㄩ崑濠囨偡娴ｉ潧鈧劙宕戦幘璇茬劦妞ゆ帒瀚悡娑㈡倵閿濆簼绨介弫鍫ユ⒑閸濆嫮鐒跨紒鎻掆偓鐔轰航闂備礁鎲＄换鍌溾偓姘煎弮瀹曟劖鎯旈埦鈧弨浠嬫煟閹邦垰鐨洪柣鎺撳劤闇夋繝濠傜凹闁垶鏌熼鍡欑瘈妞ゃ垺娲熼弫鍐焵椤掑嫭鍊峰┑鐘插閸犳劙鏌￠崘銊у⒈闁轰椒鐒︽穱濠囧Χ閸涱喖娅ら梺缁樻尭閸熸挳骞冭ぐ鎺戠倞妞ゅ繐瀚В銏㈢磽娴ｅ搫孝妞ゎ厾鍏樺濠氭晬閸曨亝鍕冮柣鐘叉处缁佹挳宕戦幘婢勬棃宕橀妸銉т喊闂備焦鐪归崹褰掓倶濮樿泛绐楅柛鈩冪⊕閻撴洟鏌￠崶銉ュ濞存粏妫勯湁缁绢參鏀辩€氾拷
		
		

        


		
		
        ////////////////////////////////////////////////////////////////////
         //闂傚倸鍊搁崐鎼佸磹瀹勬噴褰掑炊椤掑鏅悷婊冮叄閵嗗啴濡疯閻瑩鏌涢弻顓滃€愰崑鎾诲锤濡や讲鎷哄銈嗗坊閸嬫挾绱掓径濠庡殶濠㈣娲樼换婵嗩潩椤撶姴甯鹃梻浣稿閸嬪懐鎹㈤崘鈺佸灁濠靛倸鎲￠悡鐔煎箹濞ｎ剙鈧洟鎮￠幇鐗堢厪闁搞儜鍐句純閻庢鍠曠划娆愪繆濮濆矈妲归梺閫炲苯澧悽顖ょ節瀵顓奸崶鈺冿紲濠碘槅鍨靛畷鐢稿矗閸℃稒鈷戦悗鍦濞兼劙鏌涢妸銉﹀仴妤犵偛鍟撮崺锟犲川椤撶媭鍞介梻浣告贡閸庛倝骞愭繝姘兼晩濠㈣泛鐬肩壕浠嬫煕鐏炲墽鎳勭紒浣哄閵囧嫰寮埀顒勫礉濞嗘挾宓侀煫鍥ㄧ⊕閺呮悂鏌ㄩ悤鍌涘
             
		
		  debounce #(.CNT_MAX(20'd100_0000))
		  u1_key_debounce(
			  .sys_clk   		(clk),
			  .sys_rst_n 		(rst),
			  .key       		(key),   //婵犵數濮烽弫鍛婃叏閻戣棄鏋侀柛娑橈攻閸欏繐霉閸忓吋缍戦柛銊ュ€搁埞鎴﹀磼濠婂海鍔搁梺鍝勫閸庣敻寮婚垾鎰佸悑閹肩补鈧磭顔戦梻浣侯焾椤戝懘顢栨径鎰摕闁挎繂鎲橀悢灏佹瀻闁诡垎鍕靛敳缂傚倷鑳堕崑鎾诲磿閸愬樊鐒介柨鐔哄Т缁犳牗淇婇妶鍌氫壕闂佸疇妫勯ˇ顖炲煝瀹ュ鎯炴い鎰╁灮娴犺偐绱撴担鎴掑惈闁稿鍊曢悾鐑藉醇閺囥劍鏅㈡繛杈剧到閹碱偊鐛澶嬧拻濞达絿鐡旈崵鍐煕閵娿儵鍙勭€规洘锕㈤崺锟犲磼濠婂嫅姗€姊绘担绛嬪殭閻庢稈鏅犻、娆撳冀椤撶偟鐛ュ┑掳鍊撻懗鍓佺不閹€鏀介柣妯哄级閹兼劙鏌﹂崘顏勬灈闁哄被鍔岄埞鎴﹀幢閳哄倐锕傛煙椤栨粌鏋涙慨濠冩そ濡啫鈽夋潏銊愩倝姊虹粙鎸庢崳闁稿簺鍊楃划瀣箳閹惧崬浜濋梺鍛婂姀閺呮繈宕㈡禒瀣厵闁煎湱澧楄ぐ褏绱掓潏銊︾缂佸倹甯掗埥澶婎潩鏉堚晪绱叉俊鐐€栧Λ浣规叏閵堝懐鏆︾€光偓閳ь剟鍩€椤掍緡鍟忛柛鐘崇墵閳ワ箓鏌ㄧ€ｂ晝绠氶梺褰掓？缁€渚€鎮″☉妯锋斀闁绘ɑ褰冮弳鐐寸箾閸涱喗宕屾慨濠呮閹风娀鎳犻鍌ゅ敹缂傚倷鑳剁划顖炲垂閸ф绠栫憸鏂款嚕閹绢喗鍋勫〒姘煎灡闁裤倕鈹戞幊閸娧呭緤娴犲鐤い鏍仦閸嬪倿鏌曟径鍡樻珕闁绘挾鍠栭弻锟犲炊閳轰椒绮堕梺閫炲苯澧繝鈧柆宥呯劦妞ゆ帊鑳堕崯鏌ユ煙閸戙倖瀚�
			  .key_pulse			(key1_pulse)    //闂傚倸鍊搁崐鎼佸磹閹间礁纾瑰瀣捣閻棗霉閿濆浜ら柤鏉挎健濮婃椽顢楅埀顒傜矓椤曗偓閸┾偓妞ゆ帒锕﹂悾鐢碘偓瑙勬礀閵堝憡淇婃搴樺亾閿濆簼绨奸柛鐘筹耿閺岀喖顢欓悙顒佺彧缂備緡鍠楅悷鈺呯嵁閹邦厽鍎熼柨婵嗗€告禍鐐亜閹哄棗浜惧銈庝簻閸熷瓨淇婇崼鏇炲耿婵☆垳鍎ゅ▓顐︽⒒娴ｄ警鐒炬い鎴濇瀹曟繈寮撮悙鑼偒闂傚倷绀佹竟濠囧磻娓氣偓瀹曟洟寮婚妷锕€浜楅梺鍝勬川閸犲棙绂嶅鍫熺厵闁逛絻娅曞▍鍛存煃瑜滈崜姘洪悢濂夊殨闁告稑锕ラ崕鐔搞亜椤愵偄鍘哥紒銊嚙椤啴濡堕崱妤€顫囬梺鎼炲妿缁垶寮查妷鈺傗拻濞达絽鎲￠幆鍫ユ煛閸偄澧扮紒顔界懇楠炲鏁傞懖鈺冣棨婵犵數濞€濞佳囶敄閹版澘鏋侀柛鈩冾樅瑜版帗鏅查柛銉ｅ妼濞堝矂姊婚崒姘簽闁搞劏浜幑銏犫攽鐎ｎ偄浠洪梻鍌氱墛缁嬫劗鍒掗崼鏇熲拺缂備焦锕╁▓鏃堟煥閺囥劋绨婚柣锝囨焿閵囨劙骞掗幋婵堚偓顓烆渻閵堝棙鈷掗柛瀣尭閳绘挻銈ｉ崘鈹炬嫼闁荤喐鐟ョ€氼剟藟鐎ｎ亶鐔嗙憸搴ㄣ€冩繝鍌ゅ殨闁哄被鍎辩粻鐟懊归敐鍛础闁告瑥妫濆铏圭磼濡崵顦ラ梺绋匡工濠€閬嶅焵椤掍胶鍟查柟鍑ゆ嫹
		  );
		
		
		  debounce #(.CNT_MAX(20'd100_0000))
		  u2_key2_debounce(
			  .sys_clk   		(clk),
			  .sys_rst_n 		(rst),
			  .key       		(key2),   //婵犵數濮烽弫鍛婃叏閻戣棄鏋侀柛娑橈攻閸欏繐霉閸忓吋缍戦柛銊ュ€搁埞鎴﹀磼濠婂海鍔搁梺鍝勫閸庣敻寮婚垾鎰佸悑閹肩补鈧磭顔戦梻浣侯焾椤戝懘顢栨径鎰摕闁挎繂鎲橀悢灏佹瀻闁诡垎鍕靛敳缂傚倷鑳堕崑鎾诲磿閸愬樊鐒介柨鐔哄Т缁犳牗淇婇妶鍌氫壕闂佸疇妫勯ˇ顖炲煝瀹ュ鎯炴い鎰╁灮娴犺偐绱撴担鎴掑惈闁稿鍊曢悾鐑藉醇閺囥劍鏅㈡繛杈剧到閹碱偊鐛澶嬧拻濞达絿鐡旈崵鍐煕閵娿儵鍙勭€规洘锕㈤崺锟犲磼濠婂嫅姗€姊绘担绛嬪殭閻庢稈鏅犻、娆撳冀椤撶偟鐛ュ┑掳鍊撻懗鍓佺不閹€鏀介柣妯哄级閹兼劙鏌﹂崘顏勬灈闁哄被鍔岄埞鎴﹀幢閳哄倐锕傛煙椤栨粌鏋涙慨濠冩そ濡啫鈽夋潏銊愩倝姊虹粙鎸庢崳闁稿簺鍊楃划瀣箳閹惧崬浜濋梺鍛婂姀閺呮繈宕㈡禒瀣厵闁煎湱澧楄ぐ褏绱掓潏銊︾缂佸倹甯掗埥澶婎潩鏉堚晪绱叉俊鐐€栧Λ浣规叏閵堝懐鏆︾€光偓閳ь剟鍩€椤掍緡鍟忛柛鐘崇墵閳ワ箓鏌ㄧ€ｂ晝绠氶梺褰掓？缁€渚€鎮″☉妯锋斀闁绘ɑ褰冮弳鐐寸箾閸涱喗宕屾慨濠呮閹风娀鎳犻鍌ゅ敹缂傚倷鑳剁划顖炲垂閸ф绠栫憸鏂款嚕閹绢喗鍋勫〒姘煎灡闁裤倕鈹戞幊閸娧呭緤娴犲鐤い鏍仦閸嬪倿鏌曟径鍡樻珕闁绘挾鍠栭弻锟犲炊閳轰椒绮堕梺閫炲苯澧繝鈧柆宥呯劦妞ゆ帊鑳堕崯鏌ユ煙閸戙倖瀚�
			  .key_pulse			(key2_pulse)    //闂傚倸鍊搁崐鎼佸磹閹间礁纾瑰瀣捣閻棗霉閿濆浜ら柤鏉挎健濮婃椽顢楅埀顒傜矓椤曗偓閸┾偓妞ゆ帒锕﹂悾鐢碘偓瑙勬礀閵堝憡淇婃搴樺亾閿濆簼绨奸柛鐘筹耿閺岀喖顢欓悙顒佺彧缂備緡鍠楅悷鈺呯嵁閹邦厽鍎熼柨婵嗗€告禍鐐亜閹哄棗浜惧銈庝簻閸熷瓨淇婇崼鏇炲耿婵☆垳鍎ゅ▓顐︽⒒娴ｄ警鐒炬い鎴濇瀹曟繈寮撮悙鑼偒闂傚倷绀佹竟濠囧磻娓氣偓瀹曟洟寮婚妷锕€浜楅梺鍝勬川閸犲棙绂嶅鍫熺厵闁逛絻娅曞▍鍛存煃瑜滈崜姘洪悢濂夊殨闁告稑锕ラ崕鐔搞亜椤愵偄鍘哥紒銊嚙椤啴濡堕崱妤€顫囬梺鎼炲妿缁垶寮查妷鈺傗拻濞达絽鎲￠幆鍫ユ煛閸偄澧扮紒顔界懇楠炲鏁傞懖鈺冣棨婵犵數濞€濞佳囶敄閹版澘鏋侀柛鈩冾樅瑜版帗鏅查柛銉ｅ妼濞堝矂姊婚崒姘簽闁搞劏浜幑銏犫攽鐎ｎ偄浠洪梻鍌氱墛缁嬫劗鍒掗崼鏇熲拺缂備焦锕╁▓鏃堟煥閺囥劋绨婚柣锝囨焿閵囨劙骞掗幋婵堚偓顓烆渻閵堝棙鈷掗柛瀣尭閳绘挻銈ｉ崘鈹炬嫼闁荤喐鐟ョ€氼剟藟鐎ｎ亶鐔嗙憸搴ㄣ€冩繝鍌ゅ殨闁哄被鍎辩粻鐟懊归敐鍛础闁告瑥妫濆铏圭磼濡崵顦ラ梺绋匡工濠€閬嶅焵椤掍胶鍟查柟鍑ゆ嫹
		  );
		
		
		  time_cal #(.MAX_1s(12_000_000))
		  u3_time_cal
		  (
			  .clk					(clk			),
			  .rst             		(rst            ),
			  .key2_pulse      		(key2_pulse     ),
			  .oled_mode       		(oled_mode      ),
			  .curr_hour1      		(curr_hour1     ),
			  .curr_hour0      		(curr_hour0     ),
			  .curr_min1       		(curr_min1      ),
			  .curr_min0       		(curr_min0      ),
			  .curr_sec1       		(curr_sec1      ),
			  .curr_sec0       		(curr_sec0      ),
			  .next_hour1      		(next_hour1     ),
			  .next_hour0      		(next_hour0     ),
			  .next_min1       		(next_min1      ),
			  .next_min0       		(next_min0      ),
			  .next_sec1       		(next_sec1      ),
			  .next_sec0				(next_sec0		),
			  .diff_hour1            (diff_hour1   	),
			  .diff_hour0            (diff_hour0   	),
			  .diff_min1             (diff_min1    	),
			  .diff_min0             (diff_min0    	),
			  .diff_sec1             (diff_sec1    	),
			  .diff_sec0             (diff_sec0    	),
			  .beeper_start			(beeper_start	),
			  .beeper_stop		    (beeper_stop	),
			  .beeper_switch         (beeper_switch  ),
			  .beeper_en				(beeper_en		),
			  .hour					(curr_hour		)
		  );
		
		 beeper u4_beeper
		 (
			 .clk_in     			(clk),//缂傚倸鍊搁崐椋庢閿熺姴鍨傞梻鍫熺〒閺嗭箓鏌ｉ姀銈嗘锭闁搞劍绻冪换娑橆啅椤旇崵鐩庣紓渚囧亜缁夊綊寮诲☉銏╂晝闁挎繂妫涢ˇ銊╂煟鎼达綆鏆滈柟鍑ゆ嫹
			 .rst_n_in	  			(rst),//缂傚倸鍊搁崐椋庢閿熺姴鍨傞梻鍫熺〒閺嗭箓鏌ｉ姀銈嗘锭闁搞劍绻堥弻锝夊箣閻忔椿浜炲▎銏ゆ倷绾版ê浜炬鐐茬仢閸旀岸鎮楀鐓庢灓缂侇喗妫冮獮姗€顢欓悾灞藉汲婵犵數鍋為崹鍫曟晪濡炪們鍔嶉悷褏妲愰幘鎰佸悑闁告侗鍣Λ锕傛倵濞堝灝鏋涢柣蹇旇壘椤曘儵宕熼娑樹壕闁挎繂楠告禍婵嬫煟濠垫挻瀚�
			 .chose_down 			(beeper_switch),//濠电姷鏁搁崑鐐哄垂閸洖绠伴柟闂寸贰閺佸嫰鏌涢弴銊ュ箻闁告宀搁幃妤€鈽夊▎娆忓彆缂備浇椴稿Λ鍐蓟閵娾晜鍋嗛柛灞剧☉椤忥拷
			 .tone_en    			(beeper_en),//闂傚倸鍊烽懗鍫曞磻閹剧粯鍤屽Δ锝呭暙绾惧綊鎮归幁鎺戝闁活厼顦甸悡顐﹀炊閵娧€妲堥梻鍌氬亞閸ㄥ爼寮婚弴鐔虹闁割煈鍠掗崑鎾诲即閵忕姷鍘洪棅顐㈡处缁嬫帡鎮￠悩鐢电＜婵炴垶绮犲鎰版倵濮樼偓瀚�
			 .flag       			(),//缂傚倸鍊烽懗鍫曟惞鎼淬劌鐭楅幖娣妼缁愭鏌″搴″箺闁稿鏅犻弻鐔烘喆閸曨偄顫囨繛瀛樼矊缂嶅﹪寮婚悢鐓庣畾鐟滃秹寮虫潏銊ｄ簻闁靛牆鎳忛崵鍥煛瀹€鈧崰鎾舵閹烘顫呴柣妯垮皺椤旀垿姊绘担鍛婃儓闁稿﹪顥撶划鍫熺瑹閳ь剟鏁愰悙鍝勵潊妞ゎ偒鍘介崟鍐⒑缂佹ê濮﹂柛鎾跺枛瀵偊鏁撻敓锟�
			 .piano_out   			(beeper_out)//闂傚倸鍊烽懗鍫曞磻閹剧粯鍤屽Δ锝呭暙绾惧綊鎮归幁鎺戝闁活厼顦甸悡顐﹀炊閵娧€妲堥梻鍌氬亞閸ㄥ爼寮婚弴鐔虹瘈闊洦娲滈弳鐘崇箾鐎电校闁挎洏鍨藉璇测槈閵忕姷顔婇梺瑙勫劤閸熸寧鎱ㄩ崫銉х＝濞撴埃鍋撴い銈呭€垮畷锝夊礃閵娧勬濠电偛妫欓幐濠氬疾閹间焦鐓ラ柣鏇炲€圭€氾拷
		 );
		
		
		

		
        ////////////////////////////////////////////////////////////////////
        
        ////////////////////////////////////////////////////////////////////
         //濠电姷鏁搁崑娑㈩敋椤撶喐鍙忛柟顖嗏偓閺嬫牠鏌￠崶鈺佸壋闁兼澘娼￠弻銊╂偆閸屾稑顏�
             
		//wire 			beeper_start_stop;
					   
		//key_debounce #(.CNT_MAX(20'd600))
		//u1_key_debounce(
			//.sys_clk   		(clk),
			//.sys_rst_n 		(rst),
			//.key       		(key),   //婵犵數濮烽弫鍛婃叏閻戣棄鏋侀柛娑橈攻閸欏繐霉閸忓吋缍戦柛銊ュ€搁埞鎴﹀磼濠婂海鍔搁梺鍝勫閸庣敻寮婚垾鎰佸悑閹肩补鈧磭顔戦梻浣侯焾椤戝懘顢栨径鎰摕闁挎繂鎲橀悢灏佹瀻闁诡垎鍕靛敳缂傚倷鑳堕崑鎾诲磿閸愬樊鐒介柨鐔哄Т缁犳牗淇婇妶鍌氫壕闂佸疇妫勯ˇ顖炲煝瀹ュ鎯炴い鎰╁灮娴犺偐绱撴担鎴掑惈闁稿鍊曢悾鐑藉醇閺囥劍鏅㈡繛杈剧到閹碱偊鐛澶嬧拻濞达絿鐡旈崵鍐煕閵娿儵鍙勭€规洘锕㈤崺锟犲磼濠婂嫅姗€姊绘担绛嬪殭閻庢稈鏅犻、娆撳冀椤撶偟鐛ュ┑掳鍊撻懗鍓佺不閹€鏀介柣妯哄级閹兼劙鏌﹂崘顏勬灈闁哄被鍔岄埞鎴﹀幢閳哄倐锕傛煙椤栨粌鏋涙慨濠冩そ濡啫鈽夋潏銊愩倝姊虹粙鎸庢崳闁稿簺鍊楃划瀣箳閹惧崬浜濋梺鍛婂姀閺呮繈宕㈡禒瀣厵闁煎湱澧楄ぐ褏绱掓潏銊︾缂佸倹甯掗埥澶婎潩鏉堚晪绱叉俊鐐€栧Λ浣规叏閵堝懐鏆︾€光偓閳ь剟鍩€椤掍緡鍟忛柛鐘崇墵閳ワ箓鏌ㄧ€ｂ晝绠氶梺褰掓？缁€渚€鎮″☉妯锋斀闁绘ɑ褰冮弳鐐寸箾閸涱喗宕屾慨濠呮閹风娀鎳犻鍌ゅ敹缂傚倷鑳剁划顖炲垂閸ф绠栫憸鏂款嚕閹绢喗鍋勫〒姘煎灡闁裤倕鈹戞幊閸娧呭緤娴犲鐤い鏍仦閸嬪倿鏌曟径鍡樻珕闁绘挾鍠栭弻锟犲炊閳轰椒绮堕梺閫炲苯澧繝鈧柆宥呯劦妞ゆ帊鑳堕崯鏌ユ煙閸戙倖瀚�
			//.key_pulse		(key1_pulse)    //闂傚倸鍊搁崐鎼佸磹閹间礁纾瑰瀣捣閻棗霉閿濆浜ら柤鏉挎健濮婃椽顢楅埀顒傜矓椤曗偓閸┾偓妞ゆ帒锕﹂悾鐢碘偓瑙勬礀閵堝憡淇婃搴樺亾閿濆簼绨奸柛鐘筹耿閺岀喖顢欓悙顒佺彧缂備緡鍠楅悷鈺呯嵁閹邦厽鍎熼柨婵嗗€告禍鐐亜閹哄棗浜惧銈庝簻閸熷瓨淇婇崼鏇炲耿婵☆垳鍎ゅ▓顐︽⒒娴ｄ警鐒炬い鎴濇瀹曟繈寮撮悙鑼偒闂傚倷绀佹竟濠囧磻娓氣偓瀹曟洟寮婚妷锕€浜楅梺鍝勬川閸犲棙绂嶅鍫熺厵闁逛絻娅曞▍鍛存煃瑜滈崜姘洪悢濂夊殨闁告稑锕ラ崕鐔搞亜椤愵偄鍘哥紒銊嚙椤啴濡堕崱妤€顫囬梺鎼炲妿缁垶寮查妷鈺傗拻濞达絽鎲￠幆鍫ユ煛閸偄澧扮紒顔界懇楠炲鏁傞懖鈺冣棨婵犵數濞€濞佳囶敄閹版澘鏋侀柛鈩冾樅瑜版帗鏅查柛銉ｅ妼濞堝矂姊婚崒姘簽闁搞劏浜幑銏犫攽鐎ｎ偄浠洪梻鍌氱墛缁嬫劗鍒掗崼鏇熲拺缂備焦锕╁▓鏃堟煥閺囥劋绨婚柣锝囨焿閵囨劙骞掗幋婵堚偓顓烆渻閵堝棙鈷掗柛瀣尭閳绘挻銈ｉ崘鈹炬嫼闁荤喐鐟ョ€氼剟藟鐎ｎ亶鐔嗙憸搴ㄣ€冩繝鍌ゅ殨闁哄被鍎辩粻鐟懊归敐鍛础闁告瑥妫濆铏圭磼濡崵顦ラ梺绋匡工濠€閬嶅焵椤掍胶鍟查柟鍑ゆ嫹
		//);
		
		
		//key_debounce #(.CNT_MAX(20'd600))
		//u2_key2_debounce(
			//.sys_clk   		(clk),
			//.sys_rst_n 		(rst),
			//.key       		(key2),   //婵犵數濮烽弫鍛婃叏閻戣棄鏋侀柛娑橈攻閸欏繐霉閸忓吋缍戦柛銊ュ€搁埞鎴﹀磼濠婂海鍔搁梺鍝勫閸庣敻寮婚垾鎰佸悑閹肩补鈧磭顔戦梻浣侯焾椤戝懘顢栨径鎰摕闁挎繂鎲橀悢灏佹瀻闁诡垎鍕靛敳缂傚倷鑳堕崑鎾诲磿閸愬樊鐒介柨鐔哄Т缁犳牗淇婇妶鍌氫壕闂佸疇妫勯ˇ顖炲煝瀹ュ鎯炴い鎰╁灮娴犺偐绱撴担鎴掑惈闁稿鍊曢悾鐑藉醇閺囥劍鏅㈡繛杈剧到閹碱偊鐛澶嬧拻濞达絿鐡旈崵鍐煕閵娿儵鍙勭€规洘锕㈤崺锟犲磼濠婂嫅姗€姊绘担绛嬪殭閻庢稈鏅犻、娆撳冀椤撶偟鐛ュ┑掳鍊撻懗鍓佺不閹€鏀介柣妯哄级閹兼劙鏌﹂崘顏勬灈闁哄被鍔岄埞鎴﹀幢閳哄倐锕傛煙椤栨粌鏋涙慨濠冩そ濡啫鈽夋潏銊愩倝姊虹粙鎸庢崳闁稿簺鍊楃划瀣箳閹惧崬浜濋梺鍛婂姀閺呮繈宕㈡禒瀣厵闁煎湱澧楄ぐ褏绱掓潏銊︾缂佸倹甯掗埥澶婎潩鏉堚晪绱叉俊鐐€栧Λ浣规叏閵堝懐鏆︾€光偓閳ь剟鍩€椤掍緡鍟忛柛鐘崇墵閳ワ箓鏌ㄧ€ｂ晝绠氶梺褰掓？缁€渚€鎮″☉妯锋斀闁绘ɑ褰冮弳鐐寸箾閸涱喗宕屾慨濠呮閹风娀鎳犻鍌ゅ敹缂傚倷鑳剁划顖炲垂閸ф绠栫憸鏂款嚕閹绢喗鍋勫〒姘煎灡闁裤倕鈹戞幊閸娧呭緤娴犲鐤い鏍仦閸嬪倿鏌曟径鍡樻珕闁绘挾鍠栭弻锟犲炊閳轰椒绮堕梺閫炲苯澧繝鈧柆宥呯劦妞ゆ帊鑳堕崯鏌ユ煙閸戙倖瀚�
			//.key_pulse		(key2_pulse)    //闂傚倸鍊搁崐鎼佸磹閹间礁纾瑰瀣捣閻棗霉閿濆浜ら柤鏉挎健濮婃椽顢楅埀顒傜矓椤曗偓閸┾偓妞ゆ帒锕﹂悾鐢碘偓瑙勬礀閵堝憡淇婃搴樺亾閿濆簼绨奸柛鐘筹耿閺岀喖顢欓悙顒佺彧缂備緡鍠楅悷鈺呯嵁閹邦厽鍎熼柨婵嗗€告禍鐐亜閹哄棗浜惧銈庝簻閸熷瓨淇婇崼鏇炲耿婵☆垳鍎ゅ▓顐︽⒒娴ｄ警鐒炬い鎴濇瀹曟繈寮撮悙鑼偒闂傚倷绀佹竟濠囧磻娓氣偓瀹曟洟寮婚妷锕€浜楅梺鍝勬川閸犲棙绂嶅鍫熺厵闁逛絻娅曞▍鍛存煃瑜滈崜姘洪悢濂夊殨闁告稑锕ラ崕鐔搞亜椤愵偄鍘哥紒銊嚙椤啴濡堕崱妤€顫囬梺鎼炲妿缁垶寮查妷鈺傗拻濞达絽鎲￠幆鍫ユ煛閸偄澧扮紒顔界懇楠炲鏁傞懖鈺冣棨婵犵數濞€濞佳囶敄閹版澘鏋侀柛鈩冾樅瑜版帗鏅查柛銉ｅ妼濞堝矂姊婚崒姘簽闁搞劏浜幑銏犫攽鐎ｎ偄浠洪梻鍌氱墛缁嬫劗鍒掗崼鏇熲拺缂備焦锕╁▓鏃堟煥閺囥劋绨婚柣锝囨焿閵囨劙骞掗幋婵堚偓顓烆渻閵堝棙鈷掗柛瀣尭閳绘挻銈ｉ崘鈹炬嫼闁荤喐鐟ョ€氼剟藟鐎ｎ亶鐔嗙憸搴ㄣ€冩繝鍌ゅ殨闁哄被鍎辩粻鐟懊归敐鍛础闁告瑥妫濆铏圭磼濡崵顦ラ梺绋匡工濠€閬嶅焵椤掍胶鍟查柟鍑ゆ嫹
		//);
		
		
		//time_ctrl #(.MAX_1s(12_0))
		//u3_time_ctrl
		//(
			//.clk					(clk			),
			//.rst             		(rst            ),
			//.key2_pulse      		(1'b0     ),
			//.oled_mode       		(4'd0      ),
			//.curr_hour1      		(curr_hour1     ),
			//.curr_hour0      		(curr_hour0     ),
			//.curr_min1       		(curr_min1      ),
			//.curr_min0       		(curr_min0      ),
			//.curr_sec1       		(curr_sec1      ),
			//.curr_sec0       		(curr_sec0      ),
			//.next_hour1      		(next_hour1     ),
			//.next_hour0      		(next_hour0     ),
			//.next_min1       		(next_min1      ),
			//.next_min0       		(next_min0      ),
			//.next_sec1       		(next_sec1      ),
			//.next_sec0				(next_sec0		),
			//.diff_hour1             (diff_hour1   	),
			//.diff_hour0             (diff_hour0   	),
			//.diff_min1              (diff_min1    	),
			//.diff_min0              (diff_min0    	),
			//.diff_sec1              (diff_sec1    	),
			//.diff_sec0              (diff_sec0    	),
			//.beeper_start			(beeper_start	),
			//.beeper_stop		    (beeper_stop	),
			//.beeper_switch          (beeper_switch  ),
			//.beeper_en				(beeper_en		),
			//.hour					(curr_hour		)
		//);
		
		

		
		//beeper u4_beeper
		//(
			//.clk_in     			(clk),//缂傚倸鍊搁崐椋庢閿熺姴鍨傞梻鍫熺〒閺嗭箓鏌ｉ姀銈嗘锭闁搞劍绻冪换娑橆啅椤旇崵鐩庣紓渚囧亜缁夊綊寮诲☉銏╂晝闁挎繂妫涢ˇ銊╂煟鎼达綆鏆滈柟鍑ゆ嫹
			//.rst_n_in	  			(rst),//缂傚倸鍊搁崐椋庢閿熺姴鍨傞梻鍫熺〒閺嗭箓鏌ｉ姀銈嗘锭闁搞劍绻堥弻锝夊箣閻忔椿浜炲▎銏ゆ倷绾版ê浜炬鐐茬仢閸旀岸鎮楀鐓庢灓缂侇喗妫冮獮姗€顢欓悾灞藉汲婵犵數鍋為崹鍫曟晪濡炪們鍔嶉悷褏妲愰幘鎰佸悑闁告侗鍣Λ锕傛倵濞堝灝鏋涢柣蹇旇壘椤曘儵宕熼娑樹壕闁挎繂楠告禍婵嬫煟濠垫挻瀚�
			//.chose_down 			(beeper_switch),//濠电姷鏁搁崑鐐哄垂閸洖绠伴柟闂寸贰閺佸嫰鏌涢弴銊ュ箻闁告宀搁幃妤€鈽夊▎娆忓彆缂備浇椴稿Λ鍐蓟閵娾晜鍋嗛柛灞剧☉椤忥拷
			//.tone_en    			(beeper_en),//闂傚倸鍊烽懗鍫曞磻閹剧粯鍤屽Δ锝呭暙绾惧綊鎮归幁鎺戝闁活厼顦甸悡顐﹀炊閵娧€妲堥梻鍌氬亞閸ㄥ爼寮婚弴鐔虹闁割煈鍠掗崑鎾诲即閵忕姷鍘洪棅顐㈡处缁嬫帡鎮￠悩鐢电＜婵炴垶绮犲鎰版倵濮樼偓瀚�
			//.flag       			(),//缂傚倸鍊烽懗鍫曟惞鎼淬劌鐭楅幖娣妼缁愭鏌″搴″箺闁稿鏅犻弻鐔烘喆閸曨偄顫囨繛瀛樼矊缂嶅﹪寮婚悢鐓庣畾鐟滃秹寮虫潏銊ｄ簻闁靛牆鎳忛崵鍥煛瀹€鈧崰鎾舵閹烘顫呴柣妯垮皺椤旀垿姊绘担鍛婃儓闁稿﹪顥撶划鍫熺瑹閳ь剟鏁愰悙鍝勵潊妞ゎ偒鍘介崟鍐⒑缂佹ê濮﹂柛鎾跺枛瀵偊鏁撻敓锟�
			//.piano_out   			(beeper_out)//闂傚倸鍊烽懗鍫曞磻閹剧粯鍤屽Δ锝呭暙绾惧綊鎮归幁鎺戝闁活厼顦甸悡顐﹀炊閵娧€妲堥梻鍌氬亞閸ㄥ爼寮婚弴鐔虹瘈闊洦娲滈弳鐘崇箾鐎电校闁挎洏鍨藉璇测槈閵忕姷顔婇梺瑙勫劤閸熸寧鎱ㄩ崫銉х＝濞撴埃鍋撴い銈呭€垮畷锝夊礃閵娧勬濠电偛妫欓幐濠氬疾閹间焦鐓ラ柣鏇炲€圭€氾拷
		//);
		
		
        ////////////////////////////////////////////////////////////////////
		
		// tb_start_stop_gen u0_tb_start_stop_gen(
			// .clk					(clk				),
			// .rst                    (rst                ),
			// .beeper_start_stop      (beeper_start_stop  )
		// );
		
		
		// beep_player u4_beep_player
		 // (
		   // .clk_in					(clk				),//缂傚倸鍊搁崐鎼佸磹閹间礁纾归柟闂寸绾剧懓顪冪€ｎ亜顒㈡い鎰矙閺屻劑鎮㈤崫鍕戙垽鏌涢妸銉モ偓鍨潖婵犳艾閱囬柣鏃€浜介埀顒佸浮閺岋繝宕遍鐘垫殼闂佸搫鐭夌紞浣规叏閳ь剟鏌曢崼婵囶棡闂佹鍙冨娲箹閻愭彃顬夌紓浣筋嚙閸熶即骞戦姀鐘婵妫楅弲鐘差渻閵堝棙顥嗙€规洜鏁婚幆鍕償閿濆洨锛濇繛鎾磋壘濞层倖绂嶅鍛＜濠㈣泛锕︾粔铏光偓娈垮枦椤曆囧煡婢舵劕顫呴柍鍝勫€瑰▍鍥⒒娴ｇ懓顕滅紒璇插€歌灋婵炴垟鎳為崶顒€惟闁冲搫鍊婚崢浠嬫煙閼圭増褰х紓宥呮瀵啿顭ㄩ崼鐔哄幍闂佸憡鍨崐鏍偓姘炬嫹
		   // .rst_n_in				(rst				),//缂傚倸鍊搁崐鎼佸磹閹间礁纾归柟闂寸绾剧懓顪冪€ｎ亜顒㈡い鎰矙閺屻劑鎮㈤崫鍕戙垽鏌涢妸銉モ偓鍨潖婵犳艾閱囬柣鏃€浜介埀顒佸浮閺岋繝宕遍鐘垫殼闂佸搫鐭夌紞浣规叏閳ь剟鏌曢崼婵囶棡闂佹鍙冨娲箹閻愭彃顬夌紓浣筋嚙閻楁挸顕ｆ繝姘櫜濠㈣泛锕﹂娲⒑鐠囪尙绠叉俊鐐村缁傚秹鎮欏ù瀣€婚梺闈涚箞閸婃牠宕愭搴ｆ／闁绘鐓鍛洸闁绘劦鍓﹀▓浠嬫煟閹邦垰鐨哄ù鐘灲閺屾盯寮埀顒€鐣濋幖浣哥畺婵°倐鍋撴い顐ｇ箞閹剝鎯旈姀顫缂傚倸鍊风欢锟犲窗濡も偓铻為柛鎰靛枤瀹撲焦鎱ㄥ璇蹭壕濡炪們鍨洪悷鈺呭箖閸撗傛勃闁芥ê顦版潏鍫熺節閻㈤潧啸闁轰焦鎮傚畷鎴︽倷閸濆嫬鐎梺鍓插亝濞叉﹢寮查鍛箚闁绘劦浜滈埀顒佸灴瀹曟繂顓兼径瀣画閻熸粌绻愬嵄闁圭増婢樼粻濠氭煙妫颁胶顦﹂柟顔藉灴濮婃椽宕ㄦ繝浣虹箒闂侀潻缍嗛崰鏍亱闂佹寧娲栭崐褰掑磹閸偆绠鹃柛顐ｇ箘娴犮垽鏌＄€ｎ偆娲撮柡宀嬬秬缁犳盯寮崶褜妫熸俊鐐€栧ú蹇涘磿闂堟稓鏆﹂柣鏃傗拡閺佸洦绻涢幋鐏诲吋绔熼弴銏♀拺闁圭娴风粻鎾澄旈悩鍙夊暈缂佸倸绉撮埞鎴犫偓锝庡亞閸樿棄鈹戦悩鑼粵闁规瓕宕甸埀顒佺啲閹凤拷
		   // .chose_down				(beeper_switch		),//婵犵數濮烽弫鍛婃叏閻戣棄鏋侀柟闂寸绾惧鏌ｉ幇顒佹儓闁搞劌鍊块弻娑㈩敃閿濆棛顦ョ紓浣哄С閸楁娊寮婚悢鍏尖拻閻庡灚鐡曠粣妤呮⒑鏉炴壆顦﹂悗姘嵆瀵鈽夐姀鐘插祮闂侀潧顭堥崕杈╃不婵犳碍鈷戦柛娑橆煬濞堟洜鈧厜鍋撻柟闂寸缁犳牗淇婇妶鍌氫壕闂佸疇妫勯ˇ顖炲煝鎼粹檧鏋庨煫鍥ㄦ尭缁插墽绱撻崒姘偓宄懊归崶銊ｄ粓缂佸顕冲☉銏犵妞ゆ棁澹堥幗鏇㈡⒑闂堟单鍫ュ疾濠婂牆纾婚柛鈩冪⊕閻撴洟鎮橀悙鎻掆挃闁宠棄顦伴妵鍕疀閵夛箑顏�
		   // .start 					(beeper_start 		),//闂傚倸鍊搁崐宄懊归崶顒夋晪鐟滃繘鍩€椤掍胶鈻撻柡鍛█閵嗕礁鈻庨幘鍐插敤濡炪倖鎸鹃崑鐔兼偘閵夆晜鈷戦柛锔诲幖閸斿銇勯妸銉﹀櫧濠㈣娲樼换婵嗩潩椤撶姴骞嶉梻浣虹帛閸旓箓宕滃鑸靛€堕梺顒€绉甸悡娑㈡煃瑜滈崜鐔煎箠閻愬搫唯闁挎繂瀚惄搴ㄦ⒒娴ｅ憡鎯堟繛灞傚姂瀹曟垿鎮欓弽绋款樀閹瑩鎮滃Ο琛″亾閸偅鍙忔俊顖滃帶娴滈箖鎮楀鐐
		   // .stop					(beeper_stop		),
		   // .flag					(					),//缂傚倸鍊搁崐鎼佸磹閹间礁纾归柣鎴ｅГ閸ゅ嫰鏌涢锝嗙闁诡垳鍋ら獮鏍庨鈧俊濂告煟椤撶噥娈滄鐐寸墪鑿愭い鎺嗗亾濠德ゅ亹缁辨帡骞囬褎鐤侀梺鍝勫閳ь剚鍓氶崥瀣箹缁厜鍋撳畷鍥跺晥闂傚倷鑳堕…鍫ヮ敄閸岀偛鐤鹃柣妯款嚙閽冪喖鏌ｉ弮鍌氬妺闁哥姴妫濋弻娑㈠即閵娿儰绨诲銈庡亜濞诧妇鎹㈠☉姘ｅ亾濞戞瑯鐒介柣顓烇功缁辨挸顓奸崪鍐惈閻庢鍠栭…鐑藉箖閵忋倖鍋傞幖杈剧悼閺嗕即鏌ｉ悢鍝ョ煀缂佸鎳撻锝夋惞椤愶絿绉堕梺闈涱煭缁茶偐鑺辨繝姘拺闂傚牊绋撴晶鏇㈡煙閸愯尙绠荤€规洜鏁诲畷鍫曨敆娴ｅ搫骞愰柣搴″帨閸嬫捇鏌嶈閸撶喎鐣锋导鏉戠闁煎憡顔栧鐔兼⒑閸︻厼鍔嬫い銊ユ嚇閿濈偤宕ㄧ€涙鍘藉┑鈽嗗灠閻忔繈鎯冮悜妯镐簻闁哄啠鍋撻柛銊ョ仢椤繒绱掑Ο璇差€撻梺鍛婄☉閿曘儵宕曢幘缁樷拺缂佸灏呴煬顒併亜閵夛附灏甸柛鎺撳浮瀹曞ジ鎮㈤搹瑙勫殞闂備線鈧偛鑻晶鎾煛娴ｇ懓濮嶉柟顔界懇瀹曨偊宕熼崹顐ょП濠碉紕鍋戦崐銈夊磻閹烘鍌ㄥù鐘差儏缁€瀣煕閹伴潧鏋熼柍閿嬪灩缁辨挻鎷呮慨鎴簼閹便劑鏁冮崒娑氬幈闂佽宕樺▔娑㈠几濞戞埃鍋撳▓鍨珮闁稿锕顐﹀箻缂佹ɑ娅㈤梺璺ㄥ櫐閹凤拷
		   // .piano_out				(beeper				)//闂傚倸鍊搁崐鎼佸磹閹间礁纾归柣鎴ｅГ閸ゅ嫰鏌涢锝嗙缁炬儳顭烽弻鐔煎礈瑜忕敮娑㈡煕閵堝懓瀚伴摶鏍煥濠靛棙鍣归柡鍡樼懅閻ヮ亪骞嗚缁夋椽鏌熼鑲╃Ш妤犵偘绶氶獮鎺楀箣濠垫劗鈧兘姊绘担瑙勩仧闁告ê銈歌棟闁汇垹鎲￠崑鍌涖亜閹板墎鐣遍柣鎰躬閺屾洘绻涜閸嬫挻淇婇幓鎺斿ⅵ婵﹤顭峰畷鎺戭潩椤戣法鏁栭梻浣规偠閸斿矂鎮ラ悡搴殨濠电姵鑹鹃崡鎶芥煟閺冨洦顏犻柣锕€鐗撳Λ鍛搭敃閵忊€愁槱濠电偛寮剁划鎾愁嚕閹惰姤鍋愮€规洖娲ㄩ鏇㈡煟鎼达絾鏆╂い顓炵墛閻楀酣姊绘担鐟邦嚋婵炴彃绻樺畷褰掓寠婢舵ê娈ㄩ柣鐘叉处缁佹潙危閸儲鐓忛煫鍥ㄦ礀鍟稿銈嗘煥閿曨亜顫忛搹瑙勫枂闁告洦鍋勬慨銏ゆ⒑閸濄儱鏋戦悗绗涘洤绠為柕濞炬櫅娴肩娀鏌曟竟顖氭嫅缁卞啿鈹戦悙瀛樺鞍闁糕晛鍟村畷鎴﹀箻濞ｎ兛绨婚梺闈涚墕閹冲酣鍩€椤掆偓閻忔繈鎮鹃悜鑺ユ櫜濠㈣泛锕﹂ˇ銊╂⒑闂堟丹娑㈠礋椤掑鏅繝鐢靛Х閺佹悂宕戝☉妯滄稑鈻庨幘宕囶唶婵犵數濮甸懝楣冩偪妤ｅ啯鐓欓梻鍌氼嚟閸斿秹鏌ｉ幘鍗炲姦闁哄矉缍佸鎾倷濞村浜鹃柛锔诲幐閸嬫挸顫濋悙顒€顏�
		 // );
        
        
        key1_mode #(
            .OLED_MODE_MAX(4'd8)
         )
        u5_key1_mode(
            .clk                (clk        ),
            .rst                (rst        ),
            .key1_pulse         (key1_pulse ),
            .oled_mode          (oled_mode  )
         );
		 
		 
		 
		key2_mode #(
			.KEY2_MODE7_MAX(4'd3)
		)
		u6_key2_mode(
			.clk				(clk		),
			.rst                (rst        ),
			.key2_pulse         (key2_pulse ),
			.oled_mode          (oled_mode  ),
			.key2_mode7         (key2_mode7 )
		);
        
		
		oled_chinese u7_oled_chinese
		(
			.clk					(clk			),			//12MHz缂傚倸鍊搁崐鎼佸磹閹间礁纾归柟闂寸绾剧懓顪冪€ｎ亜顒㈡い鎰矙閺屻劑鎮㈤崫鍕戙垽鏌涢妸銉モ偓鍨潖婵犳艾閱囬柣鏃€浜介埀顒佸浮閺岋繝宕遍鐘垫殼闂佸搫鐭夌紞浣规叏閳ь剟鏌曢崼婵囶棡闂佹鍙冨娲箹閻愭彃顬夌紓浣筋嚙閸熶即骞戦姀鐘婵妫楅弲鐘差渻閵堝棙顥嗙€规洜鏁婚幆鍕償閿濆洨锛濇繛鎾磋壘濞层倖绂嶅鍛＜濠㈣泛锕︾粔铏光偓娈垮枦椤曆囧煡婢舵劕顫呴柍鍝勫€瑰▍鍥⒒娴ｇ懓顕滅紒璇插€歌灋婵炴垟鎳為崶顒€惟闁冲搫鍊婚崢浠嬫煙閼圭増褰х紓宥呮瀵啿顭ㄩ崼鐔哄幍闂佸憡鍨崐鏍偓姘炬嫹
			.rst					(rst			),			//缂傚倸鍊搁崐鎼佸磹閹间礁纾归柟闂寸绾剧懓顪冪€ｎ亜顒㈡い鎰矙閺屻劑鎮㈤崫鍕戙垽鏌涢妸銉モ偓鍨潖婵犳艾閱囬柣鏃€浜介埀顒佸浮閺岋繝宕遍鐘垫殼闂佸搫鐭夌紞浣规叏閳ь剟鏌曢崼婵囶棡闂佹鍙冨娲箹閻愭彃顬夌紓浣筋嚙閻楁挸顕ｆ繝姘櫜濠㈣泛锕﹂娲⒑鐠囪尙绠叉俊鐐村缁傚秹鎮欏ù瀣€婚梺闈涚箞閸婃牠宕愭搴ｆ／闁绘鐓鍛洸闁绘劦鍓﹀▓浠嬫煟閹邦垰鐨哄ù鐘灲閺屾盯寮埀顒€鐣濋幖浣哥畺婵°倐鍋撴い顐ｇ箞閹剝鎯旈姀顫缂傚倸鍊风欢锟犲窗濡も偓铻為柛鎰靛枤瀹撲焦鎱ㄥ璇蹭壕濡炪們鍨洪悷鈺呭箖閸撗傛勃闁芥ê顦版潏鍫熺節閻㈤潧啸闁轰焦鎮傚畷鎴︽倷閸濆嫬鐎梺鍓插亝濞叉﹢寮查鍛箚闁绘劦浜滈埀顒佸灴瀹曟繂顓兼径瀣画閻熸粌绻愬嵄闁圭増婢樼粻濠氭煙妫颁胶顦﹂柟顔藉灴濮婃椽宕ㄦ繝浣虹箒闂侀潻缍嗛崰鏍亱闂佹寧娲栭崐褰掑磹閸偆绠鹃柛顐ｇ箘娴犮垽鏌＄€ｎ偆娲撮柡宀嬬秬缁犳盯寮崶褜妫熸俊鐐€栧ú蹇涘磿闂堟稓鏆﹂柣鏃傗拡閺佸洦绻涢幋鐏诲吋绔熼弴銏♀拺闁圭娴风粻鎾澄旈悩鍙夊暈缂佸倸绉撮埞鎴犫偓锝庡亞閸樿棄鈹戦悩鑼粵闁规瓕宕甸埀顒佺啲閹凤拷
			.oled_mode				(oled_mode		),			
			.key2_mode7				(key2_mode7		),
			.oled_csn				(oled_csn		),			//OLCD濠电姷鏁告慨鐑藉极閸涘﹥鍙忛柣鎴ｆ閺嬩線鏌熼梻瀵割槮缁炬儳顭烽弻锝夊箛椤掍焦鍎撻梺鎼炲妼閸婂灝顫忔繝姘唶闁绘柨澧庣换渚€姊洪幖鐐测偓鏍洪悢鐓庣畺閻熸瑥瀚ㄩ崑濠囨偡娴ｉ潧鈧劙宕戦幘璇茬劦妞ゆ帒瀚悡娑㈡倵閿濆簼绨介弫鍫ユ⒑閸濆嫮鐒跨紒鎻掆偓鐔轰航闂備礁鎲＄换鍌溾偓姘煎弮瀹曟劖鎯旈埦鈧弨浠嬫煟閹邦垰鐨洪柣鎺撳劤闇夋繝濠傜凹闁垶鏌熼鍡欑瘈妞ゃ垺娲熼弫鍐焵椤掑嫭鍊峰┑鐘插閸犳劙鏌￠崘銊у⒈闁轰椒鐒︽穱濠囧Χ閸涱喖娅ら梺缁樻尭閸熸挳骞冭ぐ鎺戠倞妞ゅ繐瀚В銏㈢磽娴ｅ搫孝妞ゎ厾鍏樺濠氭晬閸曨亝鍕冮柣鐘叉处缁佹挳宕戦幘婢勬棃宕橀妸銉т喊闂備焦鐪归崹褰掓倶濮樿泛绐楅柛鈩冪⊕閻撴洟鏌￠崶銉ュ濞存粏妫勯湁缁绢參鏀辩€氾拷
			.oled_rst				(oled_rst		),			//OLCD濠电姷鏁告慨鐑藉极閸涘﹥鍙忛柣鎴ｆ閺嬩線鏌熼梻瀵割槮缁炬儳顭烽弻锝夊箛椤掍焦鍎撻梺鎼炲妼閸婂灝顫忔繝姘唶闁绘柨澧庣换渚€姊洪幖鐐测偓鏍洪悢鐓庣畺閻熸瑥瀚ㄩ崑濠囨偡娴ｉ潧鈧劙宕戦幘璇茬劦妞ゆ帒瀚悡娑㈡倵閿濆簼绨介弫鍫ユ⒑閸濆嫮鐒跨紒鎻掆偓鐔轰航闂備礁鎲＄换鍌溾偓姘煎弮瀹曟劖鎯旈埦鈧弨浠嬫煟閹邦垰鐨洪柣鎺撳劤闇夋繝濠傜凹闁垶鏌熼鍡欑瘈妞ゃ垺娲熼弫鍐焵椤掑嫭鍊峰┑鐘叉处閻撳繐鈹戦悩鑼婵＄虎鍣ｉ弻娑欐償閿熺媭鈧鏌嶇憴鍕伌婵￠箖浜堕幃妯跨疀閿濆嫰鍋楀銈冨灪娣囨椽藝鐟欏嫮绡€闁逞屽墯缁楃喖鍩€椤掆偓椤繐煤椤忓嫮顔囬柟鑹版彧缁插潡鎮鹃悽鐢电＝濞达綀娅ｇ敮娑㈡煕閵娿儳绉洪柛鈹惧亾濡炪倖甯婇懗鍫曞疮閺屻儲鐓欓柛鎴欏€栫€氾拷
			.oled_dcn				(oled_dcn		),			//OLCD闂傚倸鍊搁崐鎼佸磹閹间礁纾圭€瑰嫭鍣磋ぐ鎺戠倞鐟滄粌霉閺嶎厽鐓忓┑鐐靛亾濞呭棝鏌涢妶鍛伃闁哄被鍊楃划娆戞崉閵娿倗椹虫繝鐢靛仜閹虫劖鎱ㄩ崹顐も攳濠电姴娲ゅ洿闂佺鏈惌顔界珶閺囥垺鈷掑ù锝夘棑娑撹尙绱掗煫顓犵煓闁诡喗锚椤繃娼忛埡鍐殽闂備胶绮濠氬储瑜旈幃鐐哄垂椤愮姳绨婚梺鍦劋閸ㄧ敻顢旈銈傚亾鐟欏嫭灏紒鑸靛哺瀵鎮㈤崗鐓庝罕闂佸壊鍋嗛崰鎾诲礄閿熺姵鈷戠紓浣姑慨鍥煥閺囥劋閭€殿喖顭锋俊鎼佸煛娴ｈ櫣娼夐梻浣规偠閸庢椽鎮￠崼婢盯宕熼娑樹哗濠殿喗锕╅崣蹇涙嚀閹稿孩鍙忓┑鐘插鐢盯鏌熷畡鐗堝櫤缂佹鍠栭、娑樷槈濞嗘劖顔夐梻鍌氬€烽悞锕€顪冮崸妤€鍌ㄩ柣鎾崇瘍濞差亶鏁囬柣鎰仛濞堟儳鈹戦濮愪粶闁稿鎸搁埞鎴﹀焺閸愵亝鎲欏銈忕畱瀵爼銆冮妷鈺傚€烽柍杞版婢癸拷
			.oled_clk				(oled_clk		),			//OLCD闂傚倸鍊搁崐鎼佸磹閹间礁纾瑰瀣捣閻棗銆掑锝呬壕濡ょ姷鍋為悧鐘汇€侀弴銏℃櫇闁逞屽墴閹潡顢欐慨鎰盎闂佽婢橀悥鐓庮瀶椤曗偓閺屾稓鈧綆浜跺Σ鎼佹煃鐟欏嫬鐏寸€规洘甯掗…銊︽償閿濆懎歇缂傚倸鍊烽懗鑸垫叏閹惰棄纭€闁规儼妫勯拑鐔兼煟閺冨倸甯剁紒鐘虫皑閹茬顭ㄩ崼婵嗘優闂佺粯鏌ㄩ崥瀣偂閸愵喗鐓熼柣鏃傤焾椤ュ寮崼銉︹拺闁告繂瀚€氭壆绱掓径搴綈濞ｅ洤锕幃婊堟寠婢光斂鍔戦弻鏇熷緞濞戙垺顎嶉梺浼欒缁蹭粙鍩為幋锔藉亹闁割煈鍋呭В鍕⒑缁嬪灝顒㈤柛銊ユ健閻涱喛绠涘☉娆愭闂佽法鍣﹂幏锟�
			.oled_dat				(oled_dat		),			//OLCD闂傚倸鍊搁崐鎼佸磹閹间礁纾圭€瑰嫭鍣磋ぐ鎺戠倞鐟滄粌霉閺嶎厽鐓忓┑鐐靛亾濞呭棝鏌涢妶鍛伃闁哄被鍊楃划娆戞崉閵娿倗椹虫繝鐢靛仜閹虫劖鎱ㄩ崹顐も攳濠电姴娲ゅ洿闂佺鏈惌顔界珶閺囥垺鈷掑ù锝夘棑娑撹尙绱掗煫顓犵煓闁诡喗锚椤繄鎹勯搹璇″數闂備礁鎲＄粙鎺戭焽濞嗘挸绠查柤鍝ュ仯娴滄粓鏌熼幆褜鍤熼柍顖涙礋閺屸剝鎷呴悜妯绘瘓濠殿喖锕︾划顖炲箯閸涙潙浼犻柛鏇ㄤ簽缁憋箓姊绘担渚劸闂佸府绲剧粋宥囨崉閾忚娈惧銈嗙墱閸嬫稓绮绘导鏉戠閺夊牆澧介幃鍏笺亜閺冣偓濞茬喎顫忛搹瑙勫磯闁靛鍎查悵銏ゆ⒑閻熸澘娈╅柟鍑ゆ嫹
			.curr_hour1      		(curr_hour1     ),
			.curr_hour0      		(curr_hour0     ),
			.curr_min1       		(curr_min1      ),
			.curr_min0       		(curr_min0      ),
			.curr_sec1       		(curr_sec1      ),
			.curr_sec0       		(curr_sec0      ),
			.next_hour1      		(next_hour1     ),
			.next_hour0      		(next_hour0     ),
			.next_min1       		(next_min1      ),
			.next_min0       		(next_min0      ),
			.next_sec1       		(next_sec1      ),
			.next_sec0       		(next_sec0      ),
			.diff_hour1             (diff_hour1   	),
			.diff_hour0             (diff_hour0   	),
			.diff_min1              (diff_min1    	),
			.diff_min0              (diff_min0    	),
			.diff_sec1              (diff_sec1    	),
			.diff_sec0              (diff_sec0    	)
		);
		
		
	 ws2812	u8_ws2812
	 (
		 .clk						(clk			),
		 .rst						(rst			),
		 .start						(beeper_start	),
		 .stop                      (beeper_stop	),
		 .curr_hour                 (curr_hour		),
		 .led                    	(led_2812       )

	 );
		
		
		
        
 
        //闂傚倸鍊搁崐宄懊归崶褏鏆﹂柣銏㈩焾缁愭鏌熼柇锕€鏋涢柛銊︾箞楠炴牕菐椤掆偓閻忣亝绻涢崨顖毿ｅǎ鍥э躬婵″爼宕ㄩ鍏碱仩缂傚倷鑳舵慨鎶藉础閹惰棄钃熼柕鍫濇閸欏繘鏌熼柇锕€鍘撮柛瀣崌楠炲洭寮剁捄顭掔幢闂備浇顫夊畷姗€顢氳瀹曞綊宕掑☉鏍︾盎闂佽澹嬮弲娑㈠焵椤掍緡娈滈柟顔瑰墲瀵板嫰骞囬娑欏闂備礁鎲＄换鍌溾偓姘煎灦閿濈偤鏁冮崒娑氬幈闂佸搫鍟犻崑鎾绘煕閵娿儲鍋ュ┑鈥崇摠閹峰懐鍖栭弴鐔衡偓濠氭⒑閸︻厼浜炬繛鍏肩懇閹倿宕熼鍌滅槇闂侀潧楠忕徊鍓ф兜妤ｅ啯鐓涢柛顐亜婢ф挳鏌涢埞鍨仾闁诡垱妫冮崺锕傚焵椤掑嫬缁╁ù鐘差儐閻撶喖鏌熼柇锕€骞楃紓宥嗗灴閺岋綀绠涢妷褏鏆ら梺鍝勭灱閸犳牕鐣烽妸锔剧瘈闁告劑鍔夐崑鎾诲箛椤撴粈绨婚梺闈涢獜缁辨洘鏅堕悽纰樺亾鐟欏嫭绀€鐎规洦鍓濋悘鍐╃節閻㈤潧孝闁哥噥鍋婇幆浣割煥閸啿鎷绘繛杈剧导鐠€锕傛倿妤ｅ啯鐓涢柛顐亜婢ф壆绱掗鐣屾噰妤犵偞锚鏁堥柛銉到娴滈箖鏌涘☉妯兼憼闁搞倖鍨堕妵鍕箳瀹ュ浂妲梺鍝勵儐閸ㄥ灝螞閸涙惌鏁冮柕蹇娾偓鎰佹П缂傚倷绀侀鍡涘垂閸噮鍤曢柛娑橈功閻熷綊鏌嶈閸撶喎顕ｆ繝姘亜闁绘挸娴烽悾楣冩偡濠婂嫮鐭掔€规洜鏁婚幃銏ゅ礂閼测晛甯楃紓鍌氬€烽悞锕佹懌濡炪們鍎遍悧鎾诲蓟閿涘嫪娌柣锝呯潡閵夛负浜滅憸宀€娆㈠璺鸿摕婵炴垯鍨圭粻濠氭倵濞戞瑯鐒芥繛鍫涘€楃槐鎾寸瑹閸パ勭亶闂佽崵鍣︾粻鎴︻敋閵夆晛绀嬫い鏍ㄦ皑閻も偓闂備礁澹婇悡鍫ュ磻閸涱厸鏋嶉柛鈩冪⊕閳锋帒霉閿濆浂鐒炬い銉ョ箻閺屾稓鈧絺鏅濈粣鏃傗偓瑙勬礈椤㈠﹪濡甸幇鏉跨闁规儳纾ぐ鍐⒑鐠囨彃鍤辩紓宥呮瀹曟澘螖閸涱厾鍘遍梺纭呮彧闂勫嫰鎮￠弴銏㈠彄闁搞儯鍔嶇亸顓㈡煙椤旇棄鐏╃紒杈ㄦ尭椤撳ジ宕卞Δ鍐ф闂備線娼уú銈団偓姘嵆瀵偊宕掑鍕彴闂佽偐鈷堥崗娑橆浖閹剧粯鐓熼幖娣€ゅ鎰箾鐠囇呯暤鐎规洖婀遍幑鍕惞鐟欏嫭顔曠紓鍌欑椤戝牓顢氶幎钘夌睄闁逞屽墴楠炲繘宕ㄩ娑樻瀭闂佸憡娲﹂崢鐓庮嚈濞差亝鈷掑ù锝囩摂閸ゆ瑥螖閻樿櫕鍊愮€规洏鍨归…銊╁醇濠靛牞绱遍梻浣烘嚀婢х晫鍒掗鐐村亗闁告劦浜濋崰鎰節婵犲倻澧曠紒鈧崼銉︾厽闁哄啫鍊哥敮鍓佺磼閻樺磭澧紒缁樼洴瀹曞崬螣鐠囪尙顣查梻浣告啞椤ㄥ棙绻涙繝鍥ц摕闁挎繂顦猾宥夋煕鐏炶鈧宕濈粙娆炬富闁靛牆楠告禍鎰版煃瑜滈崜姘跺礈濮橆兙鈧帗绻濆顓犲帾闂佸壊鍋呯换鍐夊鍫熺厽闊洦宀搁崫铏圭磼缂佹鈯曠€垫澘瀚埀顒婄秵閸嬪棝藝閺夋娓婚柕鍫濆暙閻忣亝鎱ㄦ繝鍕殌妞ゎ厼娲╃粻娑樷槈濡壕鏅濋幉姝岀疀濞戣鲸鏅╅梺鍝勬储閸ㄦ椽鍩涢幋鐘电＜妞ゆ牗绋掔粈鍐┿亜鎼粹剝顥㈤柡宀嬬節瀹曘劑顢欓崜褏鍘滄俊銈囧Х閸嬫盯鏁冮妶澶嬪仼闁跨喓濮甸崐鐢告煥閻曞倹瀚�
        always @(posedge clk  or  negedge rst)begin
             if (!rst) 
                led <= 1'b0;
             else
                led <= beeper_en;
	   end     
	   
	   
        //闂傚倸鍊搁崐宄懊归崶褏鏆﹂柣銏㈩焾缁愭鏌熼柇锕€鏋涢柛銊︾箞楠炴牕菐椤掆偓閻忣亝绻涢崨顖毿ｅǎ鍥э躬婵″爼宕ㄩ鍏碱仩缂傚倷鑳舵慨鎶藉础閹惰棄钃熼柕鍫濇閸欏繘鏌熼柇锕€鍘撮柛瀣崌楠炲洭寮剁捄顭掔幢闂備浇顫夊畷姗€顢氳瀹曞綊宕掑☉鏍︾盎闂佽澹嬮弲娑㈠焵椤掍緡娈滈柟顔瑰墲瀵板嫰骞囬娑欏闂備礁鎲＄换鍌溾偓姘煎灦閿濈偤鏁冮崒娑氬幈闂佸搫鍟犻崑鎾绘煕閵娿儲鍋ュ┑鈥崇摠閹峰懐鍖栭弴鐔衡偓濠氭⒑閸︻厼浜炬繛鍏肩懇閹倿宕熼鍌滅槇闂侀潧楠忕徊鍓ф兜妤ｅ啯鐓涢柛顐亜婢ф挳鏌涢埞鍨仾闁诡垱妫冮崺锕傚焵椤掑嫬缁╁ù鐘差儐閻撶喖鏌熼柇锕€骞楃紓宥嗗灴閺岋綀绠涢妷褏鏆ら梺鍝勭灱閸犳牕鐣烽妸锔剧瘈闁告劑鍔夐崑鎾诲箛椤撴粈绨婚梺闈涢獜缁辨洘鏅堕悽纰樺亾鐟欏嫭绀€鐎规洦鍓濋悘鍐╃節閻㈤潧孝闁哥噥鍋婇幆浣割煥閸啿鎷绘繛杈剧导鐠€锕傛倿妤ｅ啯鐓涢柛顐亜婢ф壆绱掗鐣屾噰妤犵偞锚鏁堥柛銉到娴滈箖鏌涘☉妯兼憼闁搞倖鍨堕妵鍕箳瀹ュ浂妲梺鍝勵儐閸ㄥ灝螞閸涙惌鏁冮柕蹇娾偓鎰佹П缂傚倷绀侀鍡涘垂閸噮鍤曢柛娑橈功閻熷綊鏌嶈閸撶喎顕ｆ繝姘亜闁绘挸娴烽悾楣冩偡濠婂嫮鐭掔€规洜鏁婚幃銏ゅ礂閼测晛甯楃紓鍌氬€烽悞锕佹懌濡炪們鍎遍悧鎾诲蓟閿涘嫪娌柣锝呯潡閵夛负浜滅憸宀€娆㈠璺鸿摕婵炴垯鍨圭粻濠氭倵濞戞瑯鐒芥繛鍫涘€楃槐鎾寸瑹閸パ勭亶闂佽崵鍣︾粻鎴︻敋閵夆晛绀嬫い鏍ㄦ皑閻も偓闂備礁澹婇悡鍫ュ磻閸涱厸鏋嶉柛鈩冪⊕閳锋帒霉閿濆浂鐒炬い銉ョ箻閺屾稓鈧絺鏅濈粣鏃傗偓瑙勬礈椤㈠﹪濡甸幇鏉跨闁规儳纾ぐ鍐⒑鐠囨彃鍤辩紓宥呮瀹曟澘螖閸涱厾鍘遍梺纭呮彧闂勫嫰鎮￠弴銏㈠彄闁搞儯鍔嶇亸顓㈡煙椤旇棄鐏╃紒杈ㄦ尭椤撳ジ宕卞Δ鍐ф闂備線娼уú銈団偓姘嵆瀵偊宕掑鍕彴闂佽偐鈷堥崗娑橆浖閹剧粯鐓熼幖娣€ゅ鎰箾鐠囇呯暤鐎规洖婀遍幑鍕惞鐟欏嫭顔曠紓鍌欑椤戝牓顢氶幎钘夌睄闁逞屽墴楠炲繘宕ㄩ娑樻瀭闂佸憡娲﹂崢鐓庮嚈濞差亝鈷掑ù锝囩摂閸ゆ瑥螖閻樿櫕鍊愮€规洏鍨归…銊╁醇濠靛牞绱遍梻浣烘嚀婢х晫鍒掗鐐村亗闁告劦浜濋崰鎰節婵犲倻澧曠紒鈧崼銉︾厽闁哄啫鍊哥敮鍓佺磼閻樺磭澧紒缁樼洴瀹曞崬螣鐠囪尙顣查梻浣告啞椤ㄥ棙绻涙繝鍥ц摕闁挎繂顦猾宥夋煕鐏炶鈧宕濈粙娆炬富闁靛牆楠告禍鎰版煃瑜滈崜姘跺礈濮橆兙鈧帗绻濆顓犲帾闂佸壊鍋呯换鍐夊鍫熺厽闊洦宀搁崫铏圭磼缂佹鈯曠€垫澘瀚埀顒婄秵閸嬪棝藝閺夋娓婚柕鍫濆暙閻忣亝鎱ㄦ繝鍕殌妞ゎ厼娲╃粻娑樷槈濡壕鏅濋幉姝岀疀濞戣鲸鏅╅梺鍝勬储閸ㄦ椽鍩涢幋鐘电＜妞ゆ牗绋掔粈鍐┿亜鎼粹剝顥㈤柡宀嬬節瀹曘劑顢欓崜褏鍘滄俊銈囧Х閸嬫盯鏁冮妶澶嬪仼闁跨喓濮甸崐鐢告煥閻曞倹瀚�
        always @(posedge clk  or  negedge rst)begin
             if (!rst) 
                led2 <= 1'b0;
             else
                led2 <= 1'b0;
	   end 

        //闂傚倸鍊搁崐宄懊归崶褏鏆﹂柣銏㈩焾缁愭鏌熼柇锕€鏋涢柛銊︾箞楠炴牕菐椤掆偓閻忣亝绻涢崨顖毿ｅǎ鍥э躬婵″爼宕ㄩ鍏碱仩缂傚倷鑳舵慨鎶藉础閹惰棄钃熼柕鍫濇閸欏繘鏌熼柇锕€鍘撮柛瀣崌楠炲洭寮剁捄顭掔幢闂備浇顫夊畷姗€顢氳瀹曞綊宕掑☉鏍︾盎闂佽澹嬮弲娑㈠焵椤掍緡娈滈柟顔瑰墲瀵板嫰骞囬娑欏闂備礁鎲＄换鍌溾偓姘煎灦閿濈偤鏁冮崒娑氬幈闂佸搫鍟犻崑鎾绘煕閵娿儲鍋ュ┑鈥崇摠閹峰懐鍖栭弴鐔衡偓濠氭⒑閸︻厼浜炬繛鍏肩懇閹倿宕熼鍌滅槇闂侀潧楠忕徊鍓ф兜妤ｅ啯鐓涢柛顐亜婢ф挳鏌涢埞鍨仾闁诡垱妫冮崺锕傚焵椤掑嫬缁╁ù鐘差儐閻撶喖鏌熼柇锕€骞楃紓宥嗗灴閺岋綀绠涢妷褏鏆ら梺鍝勭灱閸犳牕鐣烽妸锔剧瘈闁告劑鍔夐崑鎾诲箛椤撴粈绨婚梺闈涢獜缁辨洘鏅堕悽纰樺亾鐟欏嫭绀€鐎规洦鍓濋悘鍐╃節閻㈤潧孝闁哥噥鍋婇幆浣割煥閸啿鎷绘繛杈剧导鐠€锕傛倿妤ｅ啯鐓涢柛顐亜婢ф壆绱掗鐣屾噰妤犵偞锚鏁堥柛銉到娴滈箖鏌涘☉妯兼憼闁搞倖鍨堕妵鍕箳瀹ュ浂妲梺鍝勵儐閸ㄥ灝螞閸涙惌鏁冮柕蹇娾偓鎰佹П缂傚倷绀侀鍡涘垂閸噮鍤曢柛娑橈功閻熷綊鏌嶈閸撶喎顕ｆ繝姘亜闁绘挸娴烽悾楣冩偡濠婂嫮鐭掔€规洜鏁婚幃銏ゅ礂閼测晛甯楃紓鍌氬€烽悞锕佹懌濡炪們鍎遍悧鎾诲蓟閿涘嫪娌柣锝呯潡閵夛负浜滅憸宀€娆㈠璺鸿摕婵炴垯鍨圭粻濠氭倵濞戞瑯鐒芥繛鍫涘€楃槐鎾寸瑹閸パ勭亶闂佽崵鍣︾粻鎴︻敋閵夆晛绀嬫い鏍ㄦ皑閻も偓闂備礁澹婇悡鍫ュ磻閸涱厸鏋嶉柛鈩冪⊕閳锋帒霉閿濆浂鐒炬い銉ョ箻閺屾稓鈧絺鏅濈粣鏃傗偓瑙勬礈椤㈠﹪濡甸幇鏉跨闁规儳纾ぐ鍐⒑鐠囨彃鍤辩紓宥呮瀹曟澘螖閸涱厾鍘遍梺纭呮彧闂勫嫰鎮￠弴銏㈠彄闁搞儯鍔嶇亸顓㈡煙椤旇棄鐏╃紒杈ㄦ尭椤撳ジ宕卞Δ鍐ф闂備線娼уú銈団偓姘嵆瀵偊宕掑鍕彴闂佽偐鈷堥崗娑橆浖閹剧粯鐓熼幖娣€ゅ鎰箾鐠囇呯暤鐎规洖婀遍幑鍕惞鐟欏嫭顔曠紓鍌欑椤戝牓顢氶幎钘夌睄闁逞屽墴楠炲繘宕ㄩ娑樻瀭闂佸憡娲﹂崢鐓庮嚈濞差亝鈷掑ù锝囩摂閸ゆ瑥螖閻樿櫕鍊愮€规洏鍨归…銊╁醇濠靛牞绱遍梻浣烘嚀婢х晫鍒掗鐐村亗闁告劦浜濋崰鎰節婵犲倻澧曠紒鈧崼銉︾厽闁哄啫鍊哥敮鍓佺磼閻樺磭澧紒缁樼洴瀹曞崬螣鐠囪尙顣查梻浣告啞椤ㄥ棙绻涙繝鍥ц摕闁挎繂顦猾宥夋煕鐏炶鈧宕濈粙娆炬富闁靛牆楠告禍鎰版煃瑜滈崜姘跺礈濮橆兙鈧帗绻濆顓犲帾闂佸壊鍋呯换鍐夊鍫熺厽闊洦宀搁崫铏圭磼缂佹鈯曠€垫澘瀚埀顒婄秵閸嬪棝藝閺夋娓婚柕鍫濆暙閻忣亝鎱ㄦ繝鍕殌妞ゎ厼娲╃粻娑樷槈濡壕鏅濋幉姝岀疀濞戣鲸鏅╅梺鍝勬储閸ㄦ椽鍩涢幋鐘电＜妞ゆ牗绋掔粈鍐┿亜鎼粹剝顥㈤柡宀嬬節瀹曘劑顢欓崜褏鍘滄俊銈囧Х閸嬫盯鏁冮妶澶嬪仼闁跨喓濮甸崐鐢告煥閻曞倹瀚�
        always @(posedge clk  or  negedge rst)begin
             if (!rst) 
                led_G <= 1'b1;
             else if (beeper_start)
                led_G <= ~led_G;
             else
                led_G <= led_G;
	   end 


 endmodule